package com.rfid.a252robot.activity.adapter;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rfid.a252robot.R;
import com.rfid.a252robot.base.BaseAdapter;
import com.rfid.db.bean.Book;

import java.util.List;

public class BookItemAdapter  extends BaseAdapter<BookItemAdapter.ViewHolder, Book>  {


    public BookItemAdapter(List<Book> data) {
        super(data);
    }

    @Override
    protected void bindView(ViewHolder holder, int position) {
        Book book = mData.get(position);
        String show = TextUtils.isEmpty(book.getName())?book.getBarcode():book.getName();
        holder.textView.setText((position + 1) + "、" + book.getName());
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_book1,parent,false));
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        TextView textView;
//        ImageView cover;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.bookName);
//            cover = itemView.findViewById(R.id.cover);
        }
    }
}
